<!DOCTYPE html>
<html>
<head>
<title>神经学组病例读片会</title>
<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<!-- 优先使用 IE 最新版本和 Chrome -->
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<!-- 启用360浏览器的极速模式(webkit) -->
	<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
	<!-- 添加 favicon icon -->
	<meta name="renderer" content="webkit">
	<link rel="stylesheet" href="css/public2.css" />
	<link rel="stylesheet" href="css/reset1.css" />
	<script src="js/font-size.js" type="text/javascript"></script>
	<script src="js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript">
	
	var isSuccess = 1;
	
	function nameCheck(){
		  var txt_name = $.trim($("#name").val());
		  if( txt_name.length == 0)
	      {   
			  isSuccess = 0 ;
	          $("#error").text("姓名不能为空！");
	          $("#error").css({"color":"red"});  
	      } else {
	    	  
	    	  $.ajax( {
	     			url : "nameCheck?name=" + txt_name , 
	     			type : 'post' ,
	     			datatype : 'json' , 
	     			success : function( data ){
	     				if ( data.length > 0 ) {
	     					isSuccess = 1 ;
	     					$("#error").text("");
	     				} else {
	     					$("#error").text("此姓名没有注册过,请输入正确的用户名!");
	     					$("#error").css({"color":"red"});
	     					isSuccess = 0 ;
	     				}
	     				
	     			} ,
	     			error : function(){
	     				alert( '加载失败' );
	     			}
	     			
	     	});
	    	  
	      }
	  }
			
	function phoneCheck(){
			
		var phone = $.trim( $("#phone").val() );
		
		 if( phone.length == 0)  
	     {  
	         $("#error").text("手机不能为空！");
	         $("#error").css({"color":"red"}); 
	         isSuccess = 0 ;
	     } else {
	    	 var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
	         if(!myreg.test( phone )) { 
	         	$("#error").text("请输入正确格式的手机号!");
	         	$("#error").css({"color":"red"});
	         	isSuccess = 0 ;
	         }else {
	        	 isSuccess = 1 ;	
	     	 }
	      }
	        
	}
				

	function login(){
		
		nameCheck();
    	
        if(isSuccess == 0)  
        {  
            return false;  
        }
		        
        phoneCheck();
        
        if(isSuccess == 0)  
        {   
            return false;  
        }

        var txt_name = $.trim($("#name").val());
		var txt_phone = $.trim($("#phone").val() );
		$.ajax( {
			url : 'login?name='+txt_name+"&&phone=" + txt_phone ,
			type : 'post' ,
			datatype : 'json' , 
			success : function( data ){
				if ( data == "10000" ) {
					console.info('登录成功,转向投票页面');
					window.location.href = "success.html" ;
				} else if ( data == "10001" ) {
					console.info('不存在当前用户信息!');
					$("#error").text("请重新填写登录信息!");
		         	$("#error").css({"color":"red"});
				} else {
					console.info('收到信息有误 =' + data );
				}
			} ,
			error : function(){
				alert( '加载失败' );
			}
		});
    	
	}
		
</script>
</head>

<body>

<div class="wap_phone">
    	<div class="wap">
        	<h5><span id="error" style="font-size:20px"></span></h5>
        	<form id="registerID" action="register" name="Search">
            	<p><img src="img/name.png"><input type="text" class="name" name="name"  id="name" value=""  onblur="nameCheck();" ></p>
                <p><img src="img/ph_bj.png"><input type="text" class="phone" name="phone" id="phone" value="" onblur="phoneCheck();"></p>
                <h4>
                	<input type="button" onclick="login();"  >
                </h4>
            </form>
        </div>
    </div>

</body>

	<script>
    	var t=$(window).height()
		$('.wap_phone').css('height',t+'px')
    </script>

</html>